<template>
	<view class="leave-examine-card">
		<view class="card-wrap">
			<view class="card-content"  @click="handleClick">
				<view class="card-head">
					<person-infrom :propName="leaveData.hvo.pk_psndoc.name" :propNum="leaveData.hvo.pk_psndoc.code" propDepartment=""></person-infrom>
					<view style="color: red;font-size: 24rpx; padding-top: 6rpx;">{{leaveData.hvo.billno}}</view>
				</view>
				<view class="basic-inform">
					<view class="basic-time">
						<view >
							<view class="star-time-wrap">
								<view class="time-title">开始时间:</view>
								<view class="time">{{ leaveData.hvo.realbegintime }}</view>
							</view>
							<view class="star-time-wrap">
								<view class="time-title">结束时间:</view>
								<view class="time">{{ leaveData.hvo.realendtime }}</view>
							</view>
						</view>
					</view>
					<view class="leave-inform">
						<view class="days">{{ leaveData.hvo.leavedays}}天</view>
						<view class="reason">{{leaveData.hvo.pk_leavetype.name}}</view>
					</view>
				</view>
				<view class="leave-reason" >部门:{{leaveData.hvo.pk_dept?leaveData.hvo.pk_dept.name:'未知'}}</view>
			</view>
			<view class="card-btn">
				<view class="btn-wrap">
						<assignCharacter billtype="HA02" @outConfirm="outConfirm" :formPk="leaveData.hvo.pk_leaveoff" ref="assignCharacter" action="approve"></assignCharacter>
					<!-- <view  class="take-back-btn" @click="takeback">收回</view> -->
					<!-- <my-button type="plain" @click="handleExit" height="60"  width="160">删除</my-button> -->
				</view>
				<view class="btn-wrap">
					<view class="btn-wrap-sub">
						<my-button type="plain" @click="handleExit" height="60"  width="160">销假驳回</my-button>
						<my-button @click="handleAdopt" height="62" width="160">销假通过</my-button>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	
import apiData from '../../../../common/utils/apiData.js'
import service from '../../../../common/service/new_file.js'
import utils from '../../../../common/utils/utils.js'
export default {
	name: 'leave-examine-card',
	data() {
		return {
			sumDays:0,
		};
	},
	props: {
		leaveData: {
			type: Object
		},
	},
	methods: {
		handleClick(){
			this.$emit('handleClick',this.leaveData);
		},
		deleteRec(){
			this.$emit('deleteRec', this.leaveData);
		},
		takeback(){
			this.$emit('takeback', this.leaveData);
		},
		handleExit() {
			//驳回直接就不进入指派流程
			let spr = []
			let pk = this.leaveData.hvo.pk_leaveoff
			let obj = {
				spr:spr,
				pk:pk
			}
			this.$emit('exit', obj);
		},
		outConfirm(valObj){
			//指派事件完成后才向外提交
			this.$emit('adopt',valObj);
		},
		handleAdopt() {
			//只有通过才会调用指派
			this.$refs.assignCharacter.init()
			// alert('2')
		},
		getReason(leaveType){
			let leaveArr = JSON.parse(uni.getStorageSync('leaveType'))
			let leaveshift = JSON.parse(uni.getStorageSync('leaveShift'))
			let newArr = [...leaveshift,...leaveArr]//请假的原因
			let str =utils.getLeavetyoe(newArr,leaveType)
			// console.log(str,'str')
			return str
		},
	},
	created() {
	},
	created() {
		console.log(this.leaveData)
	},	
	watch: {
		leaveData: {
			handler(newValue, oldValue) {
				console.log('改变')
			},
			deep: true
		}
	}
};
</script>

<style lang="scss" scoped>
	.take-back-btn{
		display: flex;
		justify-content: center;
		height: 60rpx;
		line-height: 60rpx;
		width: 130rpx;
		color: #FFFFFF;
		border-radius: 38rpx;
		background: #d62000;
	}
	.leave-reason{
		font-weight: 400;
		font-size: 28rpx;
		margin-bottom: 10rpx;
		color: #5b5b5b;
	}
	.card-head{
		display: flex;
		justify-content: space-between;
		.head-delete-btn{
			height: 30rpx;
			width: 40rpx;
			color: red;
		}
	}
.leave-examine-card {
	padding: 0 36rpx;
	.card-wrap {
		padding: 32rpx 28rpx 20rpx 28rpx;
		box-shadow: 0px 4px 12px 0px rgba(70, 66, 130, 0.1);
		border-radius: 8px;
		.card-content {
			border-bottom: 1px solid #e5e5e5;
			.basic-inform {
				padding: 16rpx 0 6rpx 0;
				display: flex;
				justify-content: space-between;
				.basic-time {
					font-size: 24rpx;
					.star-time-wrap {
						padding: 8rpx 0;
						display: flex;
						.time-title {
							margin-right: 10rpx;
							color: #a7a3a3;
						}
						.time {
							color: #4a4a4a;
						}
					}
				}
				.leave-inform {
					display: flex;
					flex-direction: column;
					justify-content: center;
					align-items: center;
					font-size: 30rpx;
					.days {
						font-size: 30rpx;
						color: #007AFF;
						margin-bottom: 10rpx;
					}
				}
			}
		}
		.card-btn {
			display: flex;
			padding-top: 18rpx;
			justify-content: space-between;
			.btn-wrap{
				display: flex;
				justify-content: space-between;
				.btn-wrap-sub{
					display: flex;
					justify-content: space-between;
				}
			}
		}
	}
}
</style>
